struct Sphere : Object
{
public:
    Sphere() { color = vec3{ 1, 0, 0 }; type = 1; }
    bool intersect(const vec3& rayOrig, const vec3& rayDir, IsectData& isect) const override
    {
        vec3 rayOrigc = rayOrig - center;
        float a = rayDir * rayDir;
        float b = 2 * (rayDir * rayOrigc);
        float c = rayOrigc * rayOrigc - radius * radius;

        if (!solveQuadratic(a, b, c, isect.t0, isect.t1)) return false;

        if (isect.t0 < 0) {
            if (isect.t1 < 0) return false;
            else {
                isect.inside = true;
                isect.t0 = 0;
            }
        }

        return true;
    }

    float radius{ 1 };
    vec3 center{ 0, 0, -4 };
};